package com.hospital.doctor.doctorh.service.impl;


import com.github.pagehelper.PageHelper;
import com.hospital.doctor.doctorh.dao.DoctorMapper;
import com.hospital.doctor.doctorh.entity.*;
import com.hospital.doctor.doctorh.service.DoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class DoctorServiceImpl implements DoctorService {

    @Autowired
    DoctorMapper dao;

    @Override
    public boolean selCtCount(Integer no) {
        return dao.selCtCount(no) > 0;
    }

    @Override
    public boolean selDiCount(Integer no) {
        return dao.selDiCount(no) > 0;
    }

    @Override
    public List<CtInfo> selCt(Integer no) {
        return dao.selCt(no);
    }

    @Override
    public List<DiseaseInfo> selDisease(Integer no) {
        return dao.selDisease(no);
    }

    @Override
    public List<PatientInfo> selPat(Integer doctorId, Integer start, Integer pageSeiz) {
        PageHelper.startPage(start, pageSeiz);
        return dao.selPat(doctorId);
    }

    @Override
    public List<Drugs> list() {
        return dao.list();
    }

    @Override
    public boolean insertList(List<Medicine> list, String bingli) {
        for (int i = 0; i < list.size(); i++) {
            dao.druglist(list.get(i).getUserid(), list.get(i).getUsername(), list.get(i).getMedicineid(), list.get(i).getSum(), list.get(i).getTime(), list.get(i).getDoctorid(), list.get(i).getType());
        }
        dao.druglist1(list.get(0).getUserid(), bingli, list.get(0).getTime(), list.get(0).getDoctorid());

        dao.druglist2(list.get(0).getUserid());
        return true;
    }

    @Override
    public boolean checkinsert(Integer id) {
        int usercheckselect = dao.usercheckselect(id);
        int i = dao.usercheckInsert1(id);
        if (i > 0 && usercheckselect > 0) {
            return true;
        }
        return false;
    }


}
